package white_box;

import white_box.caretaker.RoleStateCaretaker;
import white_box.originator.GameRole;

public class Client {

    public static void main(String[] args) {
        GameRole gameRole = new GameRole();
        gameRole.initState();

        System.out.println("战斗前");
        System.out.println(gameRole.toString());

        //调用管理者进行状态备份
        RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.setRoleStateMemento(gameRole.saveState());

        System.out.println("战斗后");
        gameRole.fight();
        System.out.println(gameRole.toString());

        System.out.println("调用备忘录恢复状态");
        gameRole.recoverState(roleStateCaretaker.getRoleStateMemento());
        System.out.println(gameRole.toString());
    }
}
